<template>
	<div class="customer-el-form">
		<el-form
			ref="formRef"
			:model="formData"
			:rules="formDataRules"
			:validate-on-rule-change="false"
			@validate="triggerValidate">
			<el-form-item
				label="组名"
				prop="group">
				<el-input v-model="formData.group" />
			</el-form-item>
			<el-form-item
				label="用户名"
				prop="name">
				<el-input v-model="formData.name" />
			</el-form-item>
			<el-form-item
				label="年龄"
				prop="age">
				<el-input v-model="formData.age" />
			</el-form-item>
		</el-form>
	</div>
</template>

<script setup lang="ts">
import { computed, ref } from 'vue';
import { useValidForm } from './hooks/useValidForm';

const { formRef, triggerValidate, i18n } = useValidForm();
const formData = ref({
	group: '',
	name: '',
	age: '',
});
const formDataRules = computed(() => {
	return {
		group: {
			required: true,
			message: i18n.t('user.nameEmpty'),
			trigger: ['blur', 'change'],
		},
		name: {
			required: true,
			message: i18n.t('user.nameEmpty'),
			trigger: ['blur', 'change'],
		},
		age: {
			required: true,
			message: i18n.t('user.ageEmpty'),
			trigger: ['blur', 'change'],
		},
	};
});
</script>

<style lang="scss">
</style>